using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoldDigger.Sprites;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TPL.Xna.Common;

namespace GoldDigger.Screens
{
    internal class GameOverScreen : MenuScreen
    {
        private readonly int _totalValue;
        private readonly int _targetValue;

        public GameOverScreen(int totalValue, int targetValue)
        {
            _totalValue = totalValue;
            _targetValue = targetValue;
            TransitionOnTime = TimeSpan.FromSeconds(1.0);
            TransitionOffTime = TimeSpan.FromSeconds(1.0);
        }

        public override void LoadContent()
        {
            // Common font
            var font = ScreenManager.Game.Content.Load<SpriteFont>(@"Fonts/MenuFont");

            if (_totalValue < _targetValue)
                AddSprite(new TextSprite("You did not get enough money for next stage.")
                              {
                                  Position = new Vector2(50, 100),
                                  Font = font,
                                  Color = Color.Red,
                                  Scale = 1f,
                              });
            else
                AddSprite(new TextSprite("You won.Congratulations!!!")
                              {
                                  Position = new Vector2(100, 100),
                                  Font = font,
                                  Color = Color.SpringGreen,
                                  Scale = 1.5f,
                              });

            AddSprite(new TextSprite("Total money: " + _totalValue)
                          {
                              Position = new Vector2(270, 200),
                              Font = font,
                              Color = Color.Green,
                              Scale = 1f,
                          });

            MenuEntry replay;
            AddSprite(replay = new MenuEntry("Replay")
                                   {
                                       Position = new Vector2(380, 270),
                                       Font = font,
                                       Color = Color.Gold,
                                       Scale = 0.5f,
                                   });
            replay.Tapped += (s, e) => ScreenManager.AddScreen(new MainMenuScreen());

            MenuEntry quit;
            AddSprite(quit = new MenuEntry("Quit")
                                 {
                                     Position = new Vector2(390, 300),
                                     Font = font,
                                     Color = Color.Gold,
                                     Scale = 0.5f,
                                 });
            quit.Tapped += (s, e) => ScreenManager.Game.Exit();

            _autoLayoutMenuItems = false;
            base.LoadContent();
        }
    }
}
